package cn.itcast.demo.service;

import cn.itcast.demo.dao.UserClient;
import cn.itcast.demo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserService {


    //@Autowired
    //private FakeDao fakeDao;//假的dao

    @Autowired
    private UserClient userClient;

    /**
     * 根据传入的id集合去分别查询每个id对应的对象
     * @param ids
     * @return
     */
    public List<User> queryUserByIds(List<Long> ids) {


        List<User> users = new ArrayList<>();

        ids.forEach(id->{
            users.add(userClient.queryUserById(id));
        });

        return users;
    }
}
